// Angular Version 6 below need to be deleted {providedIn: 'root'}

// angular
import {Injectable} from '@angular/core';
import {HttpParams} from '@angular/common/http';
// owner
import {Request} from 'pengesoft-ng-lib';
// models

// import {any[]} from '../domains/any[].domain';
import {RecruitmentPlan} from '../domains/recruitmentplan.domain';

/**
 * RecruitmentPlanMgeSvr
 */
@Injectable({
  providedIn: 'root'
})
export class RecruitmentPlanMgeSvrService {
  baseUrl: string;

  constructor(
    private request: Request
  ){
    this.baseUrl = 'RecruitmentPlanMgeSvr.assx/';
  }

  /**
   *
   */
  getDetailListLike(recruitmentPlan: RecruitmentPlan, param: string): Promise<any[]>{
    const httpParams = new HttpParams()
      .append('recruitmentPlan', recruitmentPlan.toString())
      .append('param', param.toString());
    return this.request.post<any[]>(this.baseUrl + 'getDetailListLike', httpParams).then((res) => {
      return res;
    });
  }

  /**
   *
   */
  addRecruitment(recruitmentPlan: RecruitmentPlan): Promise<number>{
    const httpParams = new HttpParams()
      .append('recruitmentPlan', recruitmentPlan.toString());
    return this.request.post<number>(this.baseUrl + 'addRecruitment', httpParams).then((res) => {
      return res;
    });
  }

  /**
   *
   */
  GetVersion(): Promise<string>{
    const httpParams = new HttpParams();
    return this.request.post<string>(this.baseUrl + 'GetVersion', httpParams).then((res) => {
      return res;
    });
  }

  /**
   *
   */
  updateRecruitment(recruitmentPlan: RecruitmentPlan): Promise<number>{
    const httpParams = new HttpParams()
      .append('recruitmentPlan', recruitmentPlan.toString());
    return this.request.post<number>(this.baseUrl + 'updateRecruitment', httpParams).then((res) => {
      return res;
    });
  }

  /**
   *
   */
  getDetailList(recruitmentPlan: RecruitmentPlan): Promise<any[]>{
    const httpParams = new HttpParams()
      .append('recruitmentPlan', recruitmentPlan.toString());
    return this.request.post<any[]>(this.baseUrl + 'getDetailList', httpParams).then((res) => {
      return res;
    });
  }
}
